<div class="card mb-4">
  <div class="card-header">
    <h5 class="mb-0">
      <%= Spree.t(:inventory) %>
    </h5>
  </div>
  <div class="card-body p-0">
    <table class="table">
      <thead>
        <tr>
          <th><%= Spree.t(:stock_location) %></th>
          <th>
            <%= Spree.t(:count_on_hand) %>
          </th>
          <th>
            <%= Spree.t(:backorderable) %>
          </th>
        </tr>
      </thead>
      <tbody>
        <%= f.fields_for :stock_items do |stock_item_form| %>
          <%= stock_item_form.hidden_field :id if stock_item_form.object.persisted? %>
          <%= stock_item_form.hidden_field :stock_location_id, value: stock_item_form.object.stock_location.id %>
          <tr>
            <td class="w-40">
              <%= link_to stock_item_form.object.stock_location.name, spree.edit_admin_stock_location_path(stock_item_form.object.stock_location) %>
            </td>
            <td class="w-20">
              <%= stock_item_form.number_field :count_on_hand, min: 0, class: 'form-control', disabled: !can?(:manage, stock_item_form.object) %>
            </td>
            <td class="w-40">
              <div class="custom-control custom-checkbox">
                <%= stock_item_form.check_box :backorderable, class: 'custom-control-input', disabled: !can?(:manage, stock_item_form.object) %>
                <%= stock_item_form.label :backorderable, Spree.t(:continue_selling_when_out_of_stock),class: 'custom-control-label' %>
              </div>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
    <div class="card-footer text-center bg-gray-25 text-muted">
      <%= Spree.t('admin.variants.stock_locations_link', link: spree.admin_stock_locations_path).html_safe %>
    </div>
  </div>
</div>